﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Model;
using Kaidou.Persister;
using Kaidou.Util;
using Kaidou.Bll;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
public partial class seal_seal_order_conf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
            return;
        }

        if (loginModel.isKumiaiin() && sessioncontrol.control())
        {
            Response.Redirect("../control.aspx");
        }

        try
        {
            
            Order order = (Order)Session["order"];
            TRN_JUCHU_TANTO_NAME.Text = order.getJuchu_H().JuchuTantoName;

        }catch( Exception ex){

            LogManager.error("seal_seal_order_conf "+ex.Message);
        }

    }

    protected void insertOrder(object sender, EventArgs e)
    {
        try
        {
            loginButton.Enabled = false;
            LoginModel loginModel = (LoginModel)Session["loginModel"];
            Order order = (Order)Session["order"];
            TRN_JuchuManager tjm = new TRN_JuchuManager();
            tjm.insertOrder(order, Resources.Resource.ResourceManager, loginModel, GetRootPath());

        }catch(Exception ee){
            LogManager.error("seal_seal_order_conf " + ee.Message);
            throw new Exception("insertOrder - fail" + ee.Message + ee.StackTrace);
        }

        Response.Redirect("seal_order_comp.aspx");
        
    }

    public static string GetRootPath()
    {
        string AppPath = "";
        HttpContext HttpCurrent = HttpContext.Current;
        if (HttpCurrent != null)
        {
            AppPath = HttpCurrent.Server.MapPath("~");
        }
        else
        {
            AppPath = AppDomain.CurrentDomain.BaseDirectory;
            if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success)
                AppPath = AppPath.Substring(0, AppPath.Length - 1);
        }
        return AppPath;
    }

}
